package com.danny.Controller;

import com.danny.mapper.RoomMapper;
import com.danny.pojo.Room;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class RoomController {
    @Autowired
    private RoomMapper roomMapper;
    @GetMapping("queryAllRoom")
    public List<Room> queryAllRoom(){
        return roomMapper.queryAllRoom();
    }
    @GetMapping("addRoom")
    public String addRoom(Room room){
        if(roomMapper.addRoom(room)>0)return "inserted";
        return "error";
    }
    @GetMapping("updateRoom")
    public String updateRoom(Room room){
        if(roomMapper.updateRoom(room)>0)return "updated";
        return "error";
    }
    @GetMapping("deleteRoomById")
    public String deleteRoomById(int roomNo){
        if(roomMapper.deleteRoomById(roomNo)>0)return "deleted";
        return "error";
    }

    @GetMapping("queryRoomByMulLimit")
    public List<Room> queryRoomByMulLimit(Room room,int page,int pageSize,int lowest,int highest){

        return roomMapper.queryRoomByMulLimit(room,page,pageSize,lowest,highest);
    }

    @GetMapping("queryRoomByRoomNo")
    public Room queryRoomByRoomNo(int roomNo){
        return roomMapper.queryRoomByRoomNo(roomNo);
    }

    @GetMapping("queryRoomByMul")
    public List<Room> queryRoomByMul(Room room){
        return roomMapper.queryRoomByMul(room);
    }

    @GetMapping("queryRoomLimitByNoParam")
    public List<Room> queryRoomLimitByNoParam(int page,int pageSize){
        return  roomMapper.queryRoomLimitByNoParam(page,pageSize);
    }

    @GetMapping("RoomCount")
    public int RoomCount(){
        return roomMapper.RoomCount();
    }

    @GetMapping("RoomCountHasInput")
    public int RoomCountHasInput(Room room,int lowest,int highest){
        return roomMapper.RoomCountHasInput(room,lowest,highest);
    }
}
